<!DOCTYPE HTML>
<html>
<head>
	<!--
		Tests that generated widget id's are unique according to scopeMap.
		The created widgets should get the non-conflicting generated names 
			- dijit1_dijit_layout_ContentPane_0
			- dijit2_dijit_layout_ContentPane_0

		Before running this tests, Dojo XD must be built via:
			$ cd util/buildscripts
			$ ./build.sh action=release loader=xdomain profile=standard optimize=comments
	-->
	<title>Multi-version test</title>
	<script type="text/javascript">
		djConfig = {
			baseUrl:'../../../release/dojo/dojo/',
			scopeMap:[
				['dojo','dojo1'],
				['dijit','dijit1'],
				['dojox','dojox1']
			],
			afterOnLoad: true
		};
	</script>
	<script type="text/javascript" src="../../../release/dojo/dojo/dojo.xd.js"></script>
	<script type="text/javascript">
		dojo1.require("dijit.layout.ContentPane");
		var cp1, cp2;
		dojo1.ready(function(){
			cp1 = new dijit1.layout.ContentPane({ content: 'one' });
			cp1.placeAt(dojo1.body());
			cp1.startup();

			var sc = dojo1.doc.createElement('script');
			sc.type = 'text/javascript';
			djConfig = {
				baseUrl:'../../../release/dojo/dojo/',
				scopeMap:[
					['dojo','dojo2'],
					['dijit','dijit2'],
					['dojox','dojox2']
				],
				afterOnLoad: true
			};
			sc.src = '../../../release/dojo/dojo/dojo.xd.js';
			function onScriptLoad(){
				dojo2.require("dijit.layout.ContentPane");
				dojo2.ready(function(){
					cp2 = new dijit2.layout.ContentPane({ content: 'two' });
					cp2.placeAt(dojo2.body());
					cp2.startup();

					var widgets1 = dijit1.findWidgets(dojo1.body());
					var widgets2 = dijit2.findWidgets(dojo2.body());

					dojo1.query('[widgetId='+cp1.id+']').forEach(function(n){
						var w = dijit1.byNode(n);
						if(w.domNode === n){
							console.log(w + ' matches');
						}else{
							console.log(w + ' doesn\'t match');
						}
					});
					dojo2.query('[widgetId='+cp2.id+']').forEach(function(n){
						var w = dijit2.byNode(n);
						if(w.domNode === n){
							console.log(w + ' matches');
						}else{
							console.log(w + ' doesn\'t match');
						}
					});
				});
			}
			if(typeof sc['addEventListener'] != 'undefined'){
				sc.addEventListener('load', onScriptLoad, false);
			}else{
				sc.attachEvent('onreadystatechange', onScriptLoad);
			}
			dojo1.doc.getElementsByTagName('head')[0].appendChild(sc);
		});
	</script>
</head>
<body>
</body>
</html>
